<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>带遮罩的图片背景</title>
</head>

<body>

    <div class="mask">
        <div class="image">
            <img src="../../../07-block/苏醒主题/img/index-about.png" alt="Example Image">
        </div>
        <div class="text">
            <h2>Text Content</h2>
            <p>遮罩 div 可以成功覆盖在图片之上，并实现了半透明黑色遮罩的效果，而文本内容 div 则处于遮罩之上，不受影响。</p>
        </div>
    </div>
    <style>
        .mask {
            position: relative;
        }

        .mask .image {
            position: relative;
        }

        .mask::before {
            content: '';
            background-color: rgba(0, 0, 0, 0.4);
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }

        .mask .text {
            position: relative;
            z-index: 2;
            color: #fff;
            text-align: center;
        }
    </style>
</body>

</html>